﻿using System;
using System.Collections.Generic;
using System.Xml.Linq;
using System.Text;

using ECCIT;
using OgilvyOne.UKNow.IDAL;
using OgilvyOne.UKNow.DALFactory;
using OgilvyOne.UKNow.Model;
using OgilvyOne.UKNow.DAL;
using OgilvyOne.UKNow.Utility;

namespace OgilvyOne.UKNow.BLL
{
    public class NewsPhoneImageBLL
    {
        public int LanguageID { get; set; }
        public NewsPhoneImageBLL(int langID)
        {
            this.LanguageID = langID;
        }
        public ResultInfo Save(EventsImageModel info)
        {
            IDALNewsPhoneImage use = NewsPhoneImageDALFactory.Create(LanguageID);
            info.LanguageID = LanguageID;
            return use.Save(info);
        }
        //删除单个图片的数据
        public ResultInfo delImage(int nid)
        {
            IList<int?> list = new List<int?>();
            list.Add(nid);
            IDALNewsPhoneImage use = NewsPhoneImageDALFactory.Create(LanguageID);
            return use.Delete(list);
        }
        //根据图片id 获取该图片信息
        public EventsImageModel selImage(int id)
        {
            IDALNewsPhoneImage use = NewsPhoneImageDALFactory.Create(LanguageID);
            return use.GetNewsPhoneImageModelByID(id);
        }


        //修个单个手机图片的发布状态
        public void modPubOne(int nid)
        {
            List<int?> list = new List<int?>();
            list.Add(nid);

            IDALNewsPhoneImage use = NewsPhoneImageDALFactory.Create(LanguageID);

            EventsImageModel model = use.GetNewsPhoneImageModelByID(nid); //查看该图片的当前发布状态
            if (model.State > 0) //该图片的当前为发布状态
            {
                use.UnPublish(list);
                //设置为该图片的state为0 不发布 (传递参数 eid 和 int=0)
            }
            else
            {
                use.Publish(list);
                //设置该图片的state为1 发布     (传递参数 eid 和 int=1)
            }
        }

        public IList<EventsImageModel> GetAllNewsPhoneImageModels(int? newsID)
        {
            IDALNewsPhoneImage use = NewsPhoneImageDALFactory.Create(LanguageID);
            return use.GetAllNewsPhoneImageModels(newsID);
        }

        private NewsModel GetMod(int id, int langID)
        {

            return NewsDALFactory.Create(langID).GetNewsModelByID(id);
        }
    }
}
